package day07;

import java.util.ArrayList;

public class StudentTest {
    public static void main(String[] args) {
        ArrayList<Student> list = new ArrayList<>();
        Student stu = new Student("李华", 23, "男");
        Student stu1 = new Student("黄胜", 21, "男");
        Student stu2 = new Student("苏佳威", 22, "男");
        list.add(stu);
        list.add(stu1);
        list.add(stu2);
        int max=0;
        for (int i = 0; i < list.size(); i++) {
            Student s= list.get(i);
            System.out.println(s.getName()+"---"+s.getAge()+"----"+s.sex);
            System.out.println("-------------");
           int b= s.getAge();
           if (max<b){
               max=b;
           }
        }
        for (int i = 0; i < list.size(); i++) {
            Student s1=list.get(i);
            if (max==s1.getAge()){
                s1.setName("小猪佩奇");
                System.out.println(s1.getName()+"---"+s1.getAge()+"----"+s1.sex);
                break;
            }
        }
    }
}
